# -*- coding: utf-8 -*-
# @Time    : 2019/5/22 9:49
# @Author  : Igor
# @File    : 创建进程.py
# @Software: PyCharm

from multiprocessing import Process
import time
import os


class MyProcess(Process):

    def __init__(self, i):
        super(MyProcess, self).__init__()
        self.i = i

    def run(self):
        print("进程{}--进程运行--父进程id为{}".format(self.i, os.getppid()))
        print("进程{}--进程运行--进程id为{}".format(self.i, os.getpid()))
        time.sleep(2)


if __name__ == "__main__":
    p_list = []
    for i in range(3):
        p = MyProcess(i)
        p.start()
        p_list.append(p)

    for i in p_list:
        i.join()

    print("主线程")

